package com.example.mannortycoon.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.mannortycoon.entity.SysUserEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SysUserDao extends BaseMapper<SysUserEntity> {


    SysUserEntity queryByUserName(String username);

    @Select("select rm.menu_id " +
            "from sys_role_menu as rm,sys_user_role as ur " +
            "where rm.role_id = ur.role_id and ur.user_id = #{createUserId}")
    List<Long> queryAllMenuId(Long createUserId);

    @Select("select m.perms from sys_user_role ur \n" +
            "\t\t\tLEFT JOIN sys_role_menu rm on ur.role_id = rm.role_id \n" +
            "\t\t\tLEFT JOIN sys_menu m on rm.menu_id = m.menu_id \n" +
            "\t\twhere ur.user_id = #{userId}")
    List<String> queryAllPerms(@Param("userId") Long userId);
}
